<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>何为数据代理</title>
        <script type="text/javascript" src="../js/vue.js"></script>
    </head>

    <body>
        <script type="text/javascript">
            obj1 = {
                x:100
            },

            obj2 = {
                y:200
            }

            //obj2定义新属性z，并通过其去操作obj1中的属性
            Object.defineProperty(obj2,"z",{
                //获取属性值
                get:function(){
                    return obj1.x;
                },

                //设置属性值
                set:function(value){
                    obj1.x = value;
                }
            })
        </script>
    </body>
</html>